<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>Vue</title>
  <script src="https://unpkg.com/vue"></script>
  <script src="../../dist/namedavatar-vue.js"></script>
  <style type="text/css">
  .form {
    margin: 20px auto;
  }
  .form-control {
    padding-bottom: 10px;
  }
  .form-control label {
    width: 80px;
    text-align: right;
    margin-right: 10px;
    display: inline-block;
  }
  .form-control input[type="text"], .form-control input[type="number"] {
    width: 120px;
    box-sizing: border-box;
    padding: 4px 8px;
  }
  </style>
</head>
<body>
  <div id="app">
    <div style="text-align: center;">
      <img
        v-avatar="fullName"
        :width="width"
        :height="width"
        :style="round ? 'border-radius: 100%' : ''"
      />
      <form>
        <div class="form-control">
          <label>full name</label>
          <input type="text" v-model="fullName" />
        </div>
        <div class="form-control">
          <label>width</label>
          <input type="number" v-model="width" />
        </div>
        <div class="form-control">
          <label>round</label>
          <div style="width: 120px; display: inline-block; text-align: left;">
            <input type="checkbox" v-model="round" />
          </div>
        </div>
      </form>
    </div>
  </div>

  <script>
    // quickly install directive
    Vue.directive('avatar', namedavatarVue.directive)

    // also can be install and setup options
    // Vue.use(namedavatarVue, {
    //   nameType: 'lastName'
    // })

    var app = new Vue({
      el: '#app',
      data: {
        fullName: '李连杰',
        width: 40,
        round: false,
      },
      methods: {
        humanizeURL: function (url) {
          return url
            .replace(/^https?:\/\//, '')
            .replace(/\/$/, '')
        }
      }
    })
  </script>
</body>
</html>
